package com.wans.common.exception;

import com.wans.common.constans.CustomExceptionEnum;
import lombok.Data;

import java.io.Serial;

@Data
public class CustomRunningException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = 465600000000001L;

    private Integer errorCode = 500;

    private String errorMessage = "服务器错误";

    private String errorInfo;

    public CustomRunningException(CustomExceptionEnum customExceptionEnum) {
        super(customExceptionEnum.getErrorMessage());

        this.errorCode = customExceptionEnum.getErrorCode();
        this.errorMessage = customExceptionEnum.getErrorMessage();
        this.errorInfo = customExceptionEnum.getErrorInfo();
    }

    public CustomRunningException(CustomExceptionEnum customExceptionEnum, Exception e) {


        super(customExceptionEnum.getErrorMessage(), e.getCause());

        this.errorCode = customExceptionEnum.getErrorCode();
        this.errorMessage = customExceptionEnum.getErrorMessage();
        this.errorInfo = customExceptionEnum.getErrorInfo();
    }
}
